package com.sh.controller;

import com.sh.common.Constant;
import com.sh.factory.EmployeeFactory;

import java.util.Scanner;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description: 菜单类
 */
public class Menu {
    public static void selectMenu() {
        printMenuInfo();
        Scanner scanner = new Scanner(System.in);
        String choice = scanner.nextLine();
        switch (choice) {
            case Constant.ONE:
                System.out.println("录入信息:");
                EmployeeFactory.getInstance().add();
                break;
            case Constant.TWO:
                System.out.println("查看全部职工信息:");
                EmployeeFactory.getInstance().findAll();
                break;
            case Constant.THREE:
                System.out.println("按条件查询或排序：01.按学历查询 02.按职工号排序");
                EmployeeFactory.getInstance().findByConditionOrSort();
                break;
            case Constant.FOUR:
                System.out.println("修改信息:");
                EmployeeFactory.getInstance().edit();
                break;
            case Constant.FIVE:
                System.out.println("删除信息(根据职工号进行删除):");
                EmployeeFactory.getInstance().del();
                break;
            case Constant.SIX:
                System.out.println("统计所有职工数(根据职工号进行统计):");
                EmployeeFactory.getInstance().sum();
                break;
            case Constant.SEVEN:
                System.out.println("退出系统");
                return;
            default:
                System.out.println("无此功能");
                break;
        }
        selectMenu();
    }


    public static void printMenuInfo() {
        System.out.println("**********************************************职工信息管理系统*********************************************");
        System.out.println("*1.录入信息\t2.查看全部信息\t 3.按条件查询或排序\t 4.修改信息\t 5.删除信息\t 6.统计所有职工数\t 7.退出系统*");
        System.out.println("*********************************************************************************************************");
        System.out.print("\n");
        System.out.print("请选择菜单:");
    }
}

